{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f2045d2e-f9d7-4144-ab18-16e804187238",
   "metadata": {},
   "source": [
    "### 逻辑回归  \n",
    "分类：对离散值  \n",
    "回归：对连续值  \n",
    "多变量分类：ova/ovr"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "584f255c-4faf-464b-ba0f-8c157e42c0d1",
   "metadata": {},
   "source": [
    "precision ( 精确度)：正确预测为正的，占全部预测为正的比例。  \n",
    "recall（召回率）：正确预测为正的，占全部实际为正的比例。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ddb019cb-490c-452d-b282-a588544e8411",
   "metadata": {},
   "source": [
    "## 目标任务：用LogisticRegression算法预测用户信用好坏"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "369b894c-2516-47be-9745-442e23463e9f",
   "metadata": {},
   "source": [
    "## Step1：数据理解\n",
    "- 查看数据的结构，理解每一个字段的含义\n",
    "- 简单的描述性统计分析\n",
    "- 简单的频数分析\n",
    "\n",
    "credit数据集的数据字典描述\n",
    "```\n",
    "#\t变量\t类型\t标签\n",
    "1\tchecking\t数值\tChecking Account Balance\n",
    "2\tduration\t数值\tLength of Loan\n",
    "3\thistory\t数值\tCredit History\n",
    "4\tpurpose\t字符\tReason for Loan Request\n",
    "5\tamount\t数值\tCredit Amount\n",
    "6\tsavings\t数值\tSavings Account Balance\n",
    "7\temployed\t数值\tTime at Present Employment\n",
    "8\tinstallp\t数值\tDebt as Percent of Disposable Income\n",
    "9\tmarital\t数值\tMarital Status and Gender\n",
    "10\tcoapp\t数值\tCo-applicant or Guarantor?\n",
    "11\tresident\t数值\tYears at Current Address\n",
    "12\tproperty\t数值\tCollateral Property for Loan\n",
    "13\tage\t数值\t\n",
    "14\tother\t数值\tOther Installment Loans\n",
    "15\thousing\t数值\tRent/Own\n",
    "16\texistcr\t数值\tNumber of Accounts at this Bank\n",
    "17\tjob\t数值\tEmployment Status\n",
    "18\tdepends\t数值\tNumber of Dependents\n",
    "19\ttelephon\t数值\tHas a telephone?\n",
    "20\tforeign\t数值\tForeign Worker?\n",
    "21\tgood_bad\t字符\tCredit Rating Status\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2969987d-55a7-4187-b600-287fc50427ec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>checking</th>\n",
       "      <th>duration</th>\n",
       "      <th>history</th>\n",
       "      <th>purpose</th>\n",
       "      <th>amount</th>\n",
       "      <th>savings</th>\n",
       "      <th>employed</th>\n",
       "      <th>installp</th>\n",
       "      <th>marital</th>\n",
       "      <th>coapp</th>\n",
       "      <th>...</th>\n",
       "      <th>property</th>\n",
       "      <th>age</th>\n",
       "      <th>other</th>\n",
       "      <th>housing</th>\n",
       "      <th>existcr</th>\n",
       "      <th>job</th>\n",
       "      <th>depends</th>\n",
       "      <th>telephon</th>\n",
       "      <th>foreign</th>\n",
       "      <th>good_bad</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>1169</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>67</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>48</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>5951</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>22</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>bad</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4</td>\n",
       "      <td>12</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>2096</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>49</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>42</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>7882</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>...</td>\n",
       "      <td>2</td>\n",
       "      <td>45</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>24</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>4870</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>4</td>\n",
       "      <td>53</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>bad</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   checking  duration  history purpose  amount  savings  employed  installp  \\\n",
       "0         1         6        4       3    1169        5         5         4   \n",
       "1         2        48        2       3    5951        1         3         2   \n",
       "2         4        12        4       6    2096        1         4         2   \n",
       "3         1        42        2       2    7882        1         4         2   \n",
       "4         1        24        3       0    4870        1         3         3   \n",
       "\n",
       "   marital  coapp  ...  property  age  other  housing  existcr  job  depends  \\\n",
       "0        3      1  ...         1   67      3        2        2    3        1   \n",
       "1        2      1  ...         1   22      3        2        1    3        1   \n",
       "2        3      1  ...         1   49      3        2        1    2        2   \n",
       "3        3      3  ...         2   45      3        3        1    3        2   \n",
       "4        3      1  ...         4   53      3        3        2    3        2   \n",
       "\n",
       "   telephon  foreign  good_bad  \n",
       "0         2        1      good  \n",
       "1         1        1       bad  \n",
       "2         1        1      good  \n",
       "3         1        1      good  \n",
       "4         1        1       bad  \n",
       "\n",
       "[5 rows x 21 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 利用pandas导入csv数据，查看前5行导入结果看是否正常\n",
    "import pandas as pd\n",
    "credit_df = pd.read_csv(\"../../machine-learning/datasets/credit/credit.csv\")\n",
    "credit_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ef705ffa-3063-47f5-b84d-da320cc2a63a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 1000 entries, 0 to 999\n",
      "Data columns (total 21 columns):\n",
      " #   Column    Non-Null Count  Dtype \n",
      "---  ------    --------------  ----- \n",
      " 0   checking  1000 non-null   int64 \n",
      " 1   duration  1000 non-null   int64 \n",
      " 2   history   1000 non-null   int64 \n",
      " 3   purpose   1000 non-null   object\n",
      " 4   amount    1000 non-null   int64 \n",
      " 5   savings   1000 non-null   int64 \n",
      " 6   employed  1000 non-null   int64 \n",
      " 7   installp  1000 non-null   int64 \n",
      " 8   marital   1000 non-null   int64 \n",
      " 9   coapp     1000 non-null   int64 \n",
      " 10  resident  1000 non-null   int64 \n",
      " 11  property  1000 non-null   int64 \n",
      " 12  age       1000 non-null   int64 \n",
      " 13  other     1000 non-null   int64 \n",
      " 14  housing   1000 non-null   int64 \n",
      " 15  existcr   1000 non-null   int64 \n",
      " 16  job       1000 non-null   int64 \n",
      " 17  depends   1000 non-null   int64 \n",
      " 18  telephon  1000 non-null   int64 \n",
      " 19  foreign   1000 non-null   int64 \n",
      " 20  good_bad  1000 non-null   object\n",
      "dtypes: int64(19), object(2)\n",
      "memory usage: 164.2+ KB\n"
     ]
    }
   ],
   "source": [
    "# 通过数据对象的info()函数查看数据对象的字段情况--记录数，缺失值数量，字段类型等\n",
    "credit_df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "7494fa66-86cd-48bc-8cf5-423f39d3f441",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>checking</th>\n",
       "      <th>duration</th>\n",
       "      <th>history</th>\n",
       "      <th>amount</th>\n",
       "      <th>savings</th>\n",
       "      <th>employed</th>\n",
       "      <th>installp</th>\n",
       "      <th>marital</th>\n",
       "      <th>coapp</th>\n",
       "      <th>resident</th>\n",
       "      <th>property</th>\n",
       "      <th>age</th>\n",
       "      <th>other</th>\n",
       "      <th>housing</th>\n",
       "      <th>existcr</th>\n",
       "      <th>job</th>\n",
       "      <th>depends</th>\n",
       "      <th>telephon</th>\n",
       "      <th>foreign</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.00000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.00000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "      <td>1000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>2.577000</td>\n",
       "      <td>20.903000</td>\n",
       "      <td>2.54500</td>\n",
       "      <td>3271.258000</td>\n",
       "      <td>2.105000</td>\n",
       "      <td>3.384000</td>\n",
       "      <td>2.973000</td>\n",
       "      <td>2.68200</td>\n",
       "      <td>1.145000</td>\n",
       "      <td>2.845000</td>\n",
       "      <td>2.358000</td>\n",
       "      <td>35.546000</td>\n",
       "      <td>2.675000</td>\n",
       "      <td>1.929000</td>\n",
       "      <td>1.407000</td>\n",
       "      <td>2.904000</td>\n",
       "      <td>1.155000</td>\n",
       "      <td>1.404000</td>\n",
       "      <td>1.037000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>1.257638</td>\n",
       "      <td>12.058814</td>\n",
       "      <td>1.08312</td>\n",
       "      <td>2822.736876</td>\n",
       "      <td>1.580023</td>\n",
       "      <td>1.208306</td>\n",
       "      <td>1.118715</td>\n",
       "      <td>0.70808</td>\n",
       "      <td>0.477706</td>\n",
       "      <td>1.103718</td>\n",
       "      <td>1.050209</td>\n",
       "      <td>11.375469</td>\n",
       "      <td>0.705601</td>\n",
       "      <td>0.531264</td>\n",
       "      <td>0.577654</td>\n",
       "      <td>0.653614</td>\n",
       "      <td>0.362086</td>\n",
       "      <td>0.490943</td>\n",
       "      <td>0.188856</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>250.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.00000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>19.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>12.000000</td>\n",
       "      <td>2.00000</td>\n",
       "      <td>1365.500000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2.00000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>27.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>2.000000</td>\n",
       "      <td>18.000000</td>\n",
       "      <td>2.00000</td>\n",
       "      <td>2319.500000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.00000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>33.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>4.000000</td>\n",
       "      <td>24.000000</td>\n",
       "      <td>4.00000</td>\n",
       "      <td>3972.250000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>3.00000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>42.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>4.000000</td>\n",
       "      <td>72.000000</td>\n",
       "      <td>4.00000</td>\n",
       "      <td>18424.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>4.00000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>75.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          checking     duration     history        amount      savings  \\\n",
       "count  1000.000000  1000.000000  1000.00000   1000.000000  1000.000000   \n",
       "mean      2.577000    20.903000     2.54500   3271.258000     2.105000   \n",
       "std       1.257638    12.058814     1.08312   2822.736876     1.580023   \n",
       "min       1.000000     4.000000     0.00000    250.000000     1.000000   \n",
       "25%       1.000000    12.000000     2.00000   1365.500000     1.000000   \n",
       "50%       2.000000    18.000000     2.00000   2319.500000     1.000000   \n",
       "75%       4.000000    24.000000     4.00000   3972.250000     3.000000   \n",
       "max       4.000000    72.000000     4.00000  18424.000000     5.000000   \n",
       "\n",
       "          employed     installp     marital        coapp     resident  \\\n",
       "count  1000.000000  1000.000000  1000.00000  1000.000000  1000.000000   \n",
       "mean      3.384000     2.973000     2.68200     1.145000     2.845000   \n",
       "std       1.208306     1.118715     0.70808     0.477706     1.103718   \n",
       "min       1.000000     1.000000     1.00000     1.000000     1.000000   \n",
       "25%       3.000000     2.000000     2.00000     1.000000     2.000000   \n",
       "50%       3.000000     3.000000     3.00000     1.000000     3.000000   \n",
       "75%       5.000000     4.000000     3.00000     1.000000     4.000000   \n",
       "max       5.000000     4.000000     4.00000     3.000000     4.000000   \n",
       "\n",
       "          property          age        other      housing      existcr  \\\n",
       "count  1000.000000  1000.000000  1000.000000  1000.000000  1000.000000   \n",
       "mean      2.358000    35.546000     2.675000     1.929000     1.407000   \n",
       "std       1.050209    11.375469     0.705601     0.531264     0.577654   \n",
       "min       1.000000    19.000000     1.000000     1.000000     1.000000   \n",
       "25%       1.000000    27.000000     3.000000     2.000000     1.000000   \n",
       "50%       2.000000    33.000000     3.000000     2.000000     1.000000   \n",
       "75%       3.000000    42.000000     3.000000     2.000000     2.000000   \n",
       "max       4.000000    75.000000     3.000000     3.000000     4.000000   \n",
       "\n",
       "               job      depends     telephon      foreign  \n",
       "count  1000.000000  1000.000000  1000.000000  1000.000000  \n",
       "mean      2.904000     1.155000     1.404000     1.037000  \n",
       "std       0.653614     0.362086     0.490943     0.188856  \n",
       "min       1.000000     1.000000     1.000000     1.000000  \n",
       "25%       3.000000     1.000000     1.000000     1.000000  \n",
       "50%       3.000000     1.000000     1.000000     1.000000  \n",
       "75%       3.000000     1.000000     2.000000     1.000000  \n",
       "max       4.000000     2.000000     2.000000     2.000000  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 通过数据对象的describe()函数进行简单的描述性统计分析--均值，标准差，分位数\n",
    "credit_df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "232fe9ce-9bb2-48ec-aabf-5ea5cf26b271",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "checking    0\n",
       "duration    0\n",
       "history     0\n",
       "purpose     0\n",
       "amount      0\n",
       "savings     0\n",
       "employed    0\n",
       "installp    0\n",
       "marital     0\n",
       "coapp       0\n",
       "resident    0\n",
       "property    0\n",
       "age         0\n",
       "other       0\n",
       "housing     0\n",
       "existcr     0\n",
       "job         0\n",
       "depends     0\n",
       "telephon    0\n",
       "foreign     0\n",
       "good_bad    0\n",
       "target      0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#检查空值\n",
    "credit_df.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "2243edcd-3172-46ff-b4d4-28fb53a9e10b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "purpose\n",
      "3    280\n",
      "0    234\n",
      "2    181\n",
      "1    103\n",
      "9     97\n",
      "6     50\n",
      "5     22\n",
      "4     12\n",
      "X     12\n",
      "8      9\n",
      "Name: count, dtype: int64\n",
      "good_bad\n",
      "good    700\n",
      "bad     300\n",
      "Name: count, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "# 通过value_counts()函数对类别型变量进行频数统计\n",
    "print(credit_df.purpose.value_counts())\n",
    "print(credit_df.good_bad.value_counts())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "25a5f591-59a1-430c-aef5-7bae1acc8d28",
   "metadata": {},
   "source": [
    "## Step2：数据准备\n",
    "- 类别型变量进行数字编码（one-hot独热编码）\n",
    "- 数据集拆分成train和test\n",
    "- 准备好X_train,y_train,X_test,y_test数据对象"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "da93df86-e521-4c73-8ec3-17d8c83cbcc7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>purpose_0</th>\n",
       "      <th>purpose_1</th>\n",
       "      <th>purpose_2</th>\n",
       "      <th>purpose_3</th>\n",
       "      <th>purpose_4</th>\n",
       "      <th>purpose_5</th>\n",
       "      <th>purpose_6</th>\n",
       "      <th>purpose_8</th>\n",
       "      <th>purpose_9</th>\n",
       "      <th>purpose_X</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   purpose_0  purpose_1  purpose_2  purpose_3  purpose_4  purpose_5  \\\n",
       "0      False      False      False       True      False      False   \n",
       "1      False      False      False       True      False      False   \n",
       "2      False      False      False      False      False      False   \n",
       "3      False      False       True      False      False      False   \n",
       "4       True      False      False      False      False      False   \n",
       "\n",
       "   purpose_6  purpose_8  purpose_9  purpose_X  \n",
       "0      False      False      False      False  \n",
       "1      False      False      False      False  \n",
       "2       True      False      False      False  \n",
       "3      False      False      False      False  \n",
       "4      False      False      False      False  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 把类别型变量进行独热编码(1->N)\n",
    "checking = pd.get_dummies(credit_df.checking,prefix='checking')\n",
    "history = pd.get_dummies(credit_df.history,prefix='history')\n",
    "purpose = pd.get_dummies(credit_df.purpose,prefix='purpose')\n",
    "savings = pd.get_dummies(credit_df.savings,prefix='savings')\n",
    "employed = pd.get_dummies(credit_df.employed,prefix='employed')\n",
    "installp = pd.get_dummies(credit_df.installp,prefix='installp')\n",
    "marital = pd.get_dummies(credit_df.marital,prefix='marital')\n",
    "coapp = pd.get_dummies(credit_df.coapp,prefix='coapp')\n",
    "installp = pd.get_dummies(credit_df.installp,prefix='installp')\n",
    "resident = pd.get_dummies(credit_df.resident,prefix='resident')\n",
    "property = pd.get_dummies(credit_df.property,prefix='property')\n",
    "housing = pd.get_dummies(credit_df.housing,prefix='housing')\n",
    "existcr = pd.get_dummies(credit_df.existcr,prefix='existcr')\n",
    "job = pd.get_dummies(credit_df.job,prefix='job')\n",
    "depends = pd.get_dummies(credit_df.depends,prefix='depends')\n",
    "telephon = pd.get_dummies(credit_df.telephon,prefix='telephon')\n",
    "foreign = pd.get_dummies(credit_df.foreign,prefix='foreign')\n",
    "\n",
    "# 随便查看一个编码后的数据\n",
    "purpose.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "20a46fc2-89db-4273-a9cc-0b0df9b64619",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>duration</th>\n",
       "      <th>amount</th>\n",
       "      <th>age</th>\n",
       "      <th>checking_1</th>\n",
       "      <th>checking_2</th>\n",
       "      <th>checking_3</th>\n",
       "      <th>checking_4</th>\n",
       "      <th>history_0</th>\n",
       "      <th>history_1</th>\n",
       "      <th>history_2</th>\n",
       "      <th>...</th>\n",
       "      <th>job_1</th>\n",
       "      <th>job_2</th>\n",
       "      <th>job_3</th>\n",
       "      <th>job_4</th>\n",
       "      <th>depends_1</th>\n",
       "      <th>depends_2</th>\n",
       "      <th>telephon_1</th>\n",
       "      <th>telephon_2</th>\n",
       "      <th>foreign_1</th>\n",
       "      <th>foreign_2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>6</td>\n",
       "      <td>1169</td>\n",
       "      <td>67</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>48</td>\n",
       "      <td>5951</td>\n",
       "      <td>22</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>12</td>\n",
       "      <td>2096</td>\n",
       "      <td>49</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>42</td>\n",
       "      <td>7882</td>\n",
       "      <td>45</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>24</td>\n",
       "      <td>4870</td>\n",
       "      <td>53</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 72 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   duration  amount  age  checking_1  checking_2  checking_3  checking_4  \\\n",
       "0         6    1169   67        True       False       False       False   \n",
       "1        48    5951   22       False        True       False       False   \n",
       "2        12    2096   49       False       False       False        True   \n",
       "3        42    7882   45        True       False       False       False   \n",
       "4        24    4870   53        True       False       False       False   \n",
       "\n",
       "   history_0  history_1  history_2  ...  job_1  job_2  job_3  job_4  \\\n",
       "0      False      False      False  ...  False  False   True  False   \n",
       "1      False      False       True  ...  False  False   True  False   \n",
       "2      False      False      False  ...  False   True  False  False   \n",
       "3      False      False       True  ...  False  False   True  False   \n",
       "4      False      False      False  ...  False  False   True  False   \n",
       "\n",
       "   depends_1  depends_2  telephon_1  telephon_2  foreign_1  foreign_2  \n",
       "0       True      False       False        True       True      False  \n",
       "1       True      False        True       False       True      False  \n",
       "2      False       True        True       False       True      False  \n",
       "3      False       True        True       False       True      False  \n",
       "4      False       True        True       False       True      False  \n",
       "\n",
       "[5 rows x 72 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 利用concat()函数把转换后的数据对象全部合并在一起变成新的数据对象，命名为trainData_X\n",
    "trainData_X = pd.concat([credit_df.duration, credit_df.amount, credit_df.age, checking, history, purpose, savings, employed, installp, marital, coapp, installp, resident, property, housing, existcr, job, depends, telephon, foreign], axis=1)\n",
    "trainData_X.head()\n",
    "# 72 columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "7634a6a1-6f10-41ae-b854-29cd2a07df54",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "target\n",
       "0    700\n",
       "1    300\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 构造目标变量y的数据对象\n",
    "# 当前的目标变量good_bad的取值是'good'和'bad'，一般我们习惯把二分类的类别值编码为0和1，1一般表示类别比较少的那一类，他们往往是我们感兴趣的\n",
    "credit_df['target'] = 0\n",
    "credit_df.loc[(credit_df.good_bad == 'bad'), 'target'] = 1\n",
    "\n",
    "trainData_y = credit_df['target'] \n",
    "trainData_y.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "a6a13aa3-3ea6-4670-a5b0-36aaecd79eb1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1000,)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trainData_y.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "6f46a424-bb09-41c8-99bc-7fdb8d67e553",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 拆分训练集和测试集\n",
    "from sklearn.model_selection import train_test_split\n",
    "X_train, X_test, y_train, y_test = train_test_split(trainData_X, trainData_y, test_size=0.3, random_state=123456)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "5113c377-296f-4364-bd0e-841204d6ece3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(700, 72) (300, 72)\n"
     ]
    }
   ],
   "source": [
    "# 查看一下拆分后的train和test的shape，确认拆分正确\n",
    "print(X_train.shape,X_test.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eb4d257d-f6a2-4950-9128-4d74a51238c9",
   "metadata": {},
   "source": [
    "## Step3：模型训练和调参\n",
    "- 选择一个分类算法\n",
    "- 通过fit()训练模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "a7db49d4-82da-4a4c-a90e-21f89a8b5abf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7fcf5bd036a0>]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAigAAAGiCAYAAADNzj2mAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAA6WklEQVR4nO3de3zO9eP/8efOQ47DnMYklT7KMcuh2KdJn3yUvtVHKqRSypxGWMrSweQUSSmHVJ9EJ+rTpO8a0kEf34ii6Cfk1OYUY9guu67fH6+MZeTaru11HR732+19u97Xe9e167nXZ/Z59j683kEul8slAAAALxJsOwAAAMCfUVAAAIDXoaAAAACvQ0EBAABeh4ICAAC8DgUFAAB4HQoKAADwOhQUAADgdSgoAADA61BQAACA13G7oKxcuVLdunVTnTp1FBQUpMWLF//le1asWKGWLVsqIiJCl1xyiebNm1eMqAAAIFC4XVBycnLUrFkzzZgx44Jev23bNnXt2lXx8fFat26dhgwZogceeECffvqp22EBAEBgCCrJzQKDgoK0aNEide/e/ZyvGTlypNLS0rRhw4aCbXfeeacOHTqkpUuXFvejAQCAHwst7Q9YtWqVEhISCm3r0qWLhgwZcs735ObmKjc3t+C50+nUwYMHFRUVpaCgoNKKCgAAPMjlcunIkSOqU6eOgoPdO2hT6gUlMzNT0dHRhbZFR0crOztbx48fV7ly5c56T2pqqsaOHVva0QAAQBnYuXOn6tWr59Z7Sr2gFEdycrKSkpIKnh8+fFj169fXzz//rGrVqllM5tscDoeWL1+u+Ph4hYWF2Y7j0xhLz2EsPYNx9BwbY+l0SocOSQcOSL//HvTHo3ToUNAfj9Lhw0HKzi68np0tHT9eNkcWQkNdioiQwsOlyEgpIkIKC9Mf21wKDzfrHTu6NGiQU5J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PYSx9BzG0jMYR89hLD0nuBhXebj1jurVqyskJERZWVmFtmdlZalWrVpFvqdWrVpuvR4AAMCtghIeHq5WrVopIyOjYJvT6VRGRobatm1b5Hvatm1b6PWSlJ6efs7XAwAAuH2IJykpSX369FHr1q3Vpk0bTZ06VTk5Oerbt68kqXfv3qpbt65SU1MlSYMHD1bHjh01efJkde3aVQsWLNC3336rV1999YI/MyIiQikpKUUe9sGFYxw9h7H0HMbSMxhHz2EsPackY+n2ZcaS9OKLLxZM1Na8eXO98MILiouLkyR16tRJsbGxmjdvXsHr3333XT3++OMFE7VNmDCh1CdqAwAAvqtYBQUAAKA0MXk6AADwOhQUAADgdSgoAADA61BQAACA1/HJgpKWlqa4uDiVK1dOVatWVffu3W1H8mm5ublq3ry5goKCtG7dOttxfMr27dt1//33q2HDhipXrpwaNWqklJQU5eXl2Y7mE2bMmKHY2FhFRkYqLi5Oq1evth3J56Smpurqq69WxYoVVbNmTXXv3l2bN2+2HcvnjR8/XkFBQRoyZIjtKD5p9+7duueeexQVFaVy5crpyiuv1LfffuvW9/C5gvL++++rV69e6tu3r9avX6+vvvpKd911l+1YPm3EiBGqU6eO7Rg+adOmTXI6nXrllVe0ceNGPf/885o5c6Yee+wx29G83sKFC5WUlKSUlBStXbtWzZo1U5cuXbR3717b0XzK559/rgEDBuibb75Renq6HA6HbrjhBuVwd9Ri+7//+z+98soruuqqq2xH8Um///672rdvr7CwMH3yySf68ccfNXnyZFWtWtW9b+TyIQ6Hw1W3bl3X7NmzbUfxG0uWLHFdfvnlro0bN7okub777jvbkXzehAkTXA0bNrQdw+u1adPGNWDAgILn+fn5rjp16rhSU1MtpvJ9e/fudUlyff7557aj+KQjR464Gjdu7EpPT3d17NjRNXjwYNuRfM7IkSNdHTp0KPH38ak9KGvXrtXu3bsVHBysFi1aqHbt2vrHP/6hDRs22I7mk7KystSvXz+9+eabKl++vO04fuPw4cPFunNnIMnLy9OaNWuUkJBQsC04OFgJCQlatWqVxWS+7/Dhw5LE72Ax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cmWVK1fOcjrfUbFixbPO26lQoYKioqI4n8dNQ4cOVbt27TRu3Dj961//0urVq/Xqq6+6vXfZpwqKJE2cOFGhoaHq1auXjh8/rri4OC1btsz966sBD0hPT9eWLVu0ZcuWs4qdixuFn1ePHj20b98+jRkzRpmZmWrevLmWLl161omzOL+XX35ZktSpU6dC21977bW/PEwJlIarr75aixYtUnJysp566ik1bNhQU6dO1d133+3W9wly8VcUAAB4GQ6WAwAAr0NBAQAAXoeCAgAAvA4FBQAAeB0KCgAA8DoUFAAA4HUoKAAAwOtQUAAAgNehoAAAAK9DQQEAAF6HggIAALzO/wecOitZUgJzCQAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 了解一下sigmoid曲线\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline \n",
    "import numpy as np\n",
    "\n",
    "plt.figure()\n",
    "plt.axis([-6,6,0,1])\n",
    "plt.grid(True)\n",
    "X=np.arange(-6,6,0.1)\n",
    "\n",
    "#sigmoid函数\n",
    "y=1/(1+np.e**(-X))\n",
    "\n",
    "plt.plot(X,y,'b-')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "531b909b-bda6-4d50-8801-f456e480cee8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>#sk-container-id-1 {\n",
       "  /* Definition of color scheme common for light and dark mode */\n",
       "  --sklearn-color-text: black;\n",
       "  --sklearn-color-line: gray;\n",
       "  /* Definition of color scheme for unfitted estimators */\n",
       "  --sklearn-color-unfitted-level-0: #fff5e6;\n",
       "  --sklearn-color-unfitted-level-1: #f6e4d2;\n",
       "  --sklearn-color-unfitted-level-2: #ffe0b3;\n",
       "  --sklearn-color-unfitted-level-3: chocolate;\n",
       "  /* Definition of color scheme for fitted estimators */\n",
       "  --sklearn-color-fitted-level-0: #f0f8ff;\n",
       "  --sklearn-color-fitted-level-1: #d4ebff;\n",
       "  --sklearn-color-fitted-level-2: #b3dbfd;\n",
       "  --sklearn-color-fitted-level-3: cornflowerblue;\n",
       "\n",
       "  /* Specific color for light theme */\n",
       "  --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
       "  --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n",
       "  --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
       "  --sklearn-color-icon: #696969;\n",
       "\n",
       "  @media (prefers-color-scheme: dark) {\n",
       "    /* Redefinition of color scheme for dark theme */\n",
       "    --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
       "    --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n",
       "    --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
       "    --sklearn-color-icon: #878787;\n",
       "  }\n",
       "}\n",
       "\n",
       "#sk-container-id-1 {\n",
       "  color: var(--sklearn-color-text);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 pre {\n",
       "  padding: 0;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 input.sk-hidden--visually {\n",
       "  border: 0;\n",
       "  clip: rect(1px 1px 1px 1px);\n",
       "  clip: rect(1px, 1px, 1px, 1px);\n",
       "  height: 1px;\n",
       "  margin: -1px;\n",
       "  overflow: hidden;\n",
       "  padding: 0;\n",
       "  position: absolute;\n",
       "  width: 1px;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-dashed-wrapped {\n",
       "  border: 1px dashed var(--sklearn-color-line);\n",
       "  margin: 0 0.4em 0.5em 0.4em;\n",
       "  box-sizing: border-box;\n",
       "  padding-bottom: 0.4em;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-container {\n",
       "  /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
       "     but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
       "     so we also need the `!important` here to be able to override the\n",
       "     default hidden behavior on the sphinx rendered scikit-learn.org.\n",
       "     See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
       "  display: inline-block !important;\n",
       "  position: relative;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-text-repr-fallback {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       "div.sk-parallel-item,\n",
       "div.sk-serial,\n",
       "div.sk-item {\n",
       "  /* draw centered vertical line to link estimators */\n",
       "  background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
       "  background-size: 2px 100%;\n",
       "  background-repeat: no-repeat;\n",
       "  background-position: center center;\n",
       "}\n",
       "\n",
       "/* Parallel-specific style estimator block */\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item::after {\n",
       "  content: \"\";\n",
       "  width: 100%;\n",
       "  border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
       "  flex-grow: 1;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel {\n",
       "  display: flex;\n",
       "  align-items: stretch;\n",
       "  justify-content: center;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "  position: relative;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item {\n",
       "  display: flex;\n",
       "  flex-direction: column;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item:first-child::after {\n",
       "  align-self: flex-end;\n",
       "  width: 50%;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item:last-child::after {\n",
       "  align-self: flex-start;\n",
       "  width: 50%;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item:only-child::after {\n",
       "  width: 0;\n",
       "}\n",
       "\n",
       "/* Serial-specific style estimator block */\n",
       "\n",
       "#sk-container-id-1 div.sk-serial {\n",
       "  display: flex;\n",
       "  flex-direction: column;\n",
       "  align-items: center;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "  padding-right: 1em;\n",
       "  padding-left: 1em;\n",
       "}\n",
       "\n",
       "\n",
       "/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
       "clickable and can be expanded/collapsed.\n",
       "- Pipeline and ColumnTransformer use this feature and define the default style\n",
       "- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
       "*/\n",
       "\n",
       "/* Pipeline and ColumnTransformer style (default) */\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable {\n",
       "  /* Default theme specific background. It is overwritten whether we have a\n",
       "  specific estimator or a Pipeline/ColumnTransformer */\n",
       "  background-color: var(--sklearn-color-background);\n",
       "}\n",
       "\n",
       "/* Toggleable label */\n",
       "#sk-container-id-1 label.sk-toggleable__label {\n",
       "  cursor: pointer;\n",
       "  display: block;\n",
       "  width: 100%;\n",
       "  margin-bottom: 0;\n",
       "  padding: 0.5em;\n",
       "  box-sizing: border-box;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 label.sk-toggleable__label-arrow:before {\n",
       "  /* Arrow on the left of the label */\n",
       "  content: \"▸\";\n",
       "  float: left;\n",
       "  margin-right: 0.25em;\n",
       "  color: var(--sklearn-color-icon);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {\n",
       "  color: var(--sklearn-color-text);\n",
       "}\n",
       "\n",
       "/* Toggleable content - dropdown */\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable__content {\n",
       "  max-height: 0;\n",
       "  max-width: 0;\n",
       "  overflow: hidden;\n",
       "  text-align: left;\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable__content.fitted {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable__content pre {\n",
       "  margin: 0.2em;\n",
       "  border-radius: 0.25em;\n",
       "  color: var(--sklearn-color-text);\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable__content.fitted pre {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
       "  /* Expand drop-down */\n",
       "  max-height: 200px;\n",
       "  max-width: 100%;\n",
       "  overflow: auto;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
       "  content: \"▾\";\n",
       "}\n",
       "\n",
       "/* Pipeline/ColumnTransformer-specific style */\n",
       "\n",
       "#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
       "  color: var(--sklearn-color-text);\n",
       "  background-color: var(--sklearn-color-unfitted-level-2);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
       "  background-color: var(--sklearn-color-fitted-level-2);\n",
       "}\n",
       "\n",
       "/* Estimator-specific style */\n",
       "\n",
       "/* Colorize estimator box */\n",
       "#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-2);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-2);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-label label.sk-toggleable__label,\n",
       "#sk-container-id-1 div.sk-label label {\n",
       "  /* The background is the default theme color */\n",
       "  color: var(--sklearn-color-text-on-default-background);\n",
       "}\n",
       "\n",
       "/* On hover, darken the color of the background */\n",
       "#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {\n",
       "  color: var(--sklearn-color-text);\n",
       "  background-color: var(--sklearn-color-unfitted-level-2);\n",
       "}\n",
       "\n",
       "/* Label box, darken color on hover, fitted */\n",
       "#sk-container-id-1 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
       "  color: var(--sklearn-color-text);\n",
       "  background-color: var(--sklearn-color-fitted-level-2);\n",
       "}\n",
       "\n",
       "/* Estimator label */\n",
       "\n",
       "#sk-container-id-1 div.sk-label label {\n",
       "  font-family: monospace;\n",
       "  font-weight: bold;\n",
       "  display: inline-block;\n",
       "  line-height: 1.2em;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-label-container {\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       "/* Estimator-specific */\n",
       "#sk-container-id-1 div.sk-estimator {\n",
       "  font-family: monospace;\n",
       "  border: 1px dotted var(--sklearn-color-border-box);\n",
       "  border-radius: 0.25em;\n",
       "  box-sizing: border-box;\n",
       "  margin-bottom: 0.5em;\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-estimator.fitted {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-0);\n",
       "}\n",
       "\n",
       "/* on hover */\n",
       "#sk-container-id-1 div.sk-estimator:hover {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-2);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-estimator.fitted:hover {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-2);\n",
       "}\n",
       "\n",
       "/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
       "\n",
       "/* Common style for \"i\" and \"?\" */\n",
       "\n",
       ".sk-estimator-doc-link,\n",
       "a:link.sk-estimator-doc-link,\n",
       "a:visited.sk-estimator-doc-link {\n",
       "  float: right;\n",
       "  font-size: smaller;\n",
       "  line-height: 1em;\n",
       "  font-family: monospace;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "  border-radius: 1em;\n",
       "  height: 1em;\n",
       "  width: 1em;\n",
       "  text-decoration: none !important;\n",
       "  margin-left: 1ex;\n",
       "  /* unfitted */\n",
       "  border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
       "  color: var(--sklearn-color-unfitted-level-1);\n",
       "}\n",
       "\n",
       ".sk-estimator-doc-link.fitted,\n",
       "a:link.sk-estimator-doc-link.fitted,\n",
       "a:visited.sk-estimator-doc-link.fitted {\n",
       "  /* fitted */\n",
       "  border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
       "  color: var(--sklearn-color-fitted-level-1);\n",
       "}\n",
       "\n",
       "/* On hover */\n",
       "div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
       ".sk-estimator-doc-link:hover,\n",
       "div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
       ".sk-estimator-doc-link:hover {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-3);\n",
       "  color: var(--sklearn-color-background);\n",
       "  text-decoration: none;\n",
       "}\n",
       "\n",
       "div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
       ".sk-estimator-doc-link.fitted:hover,\n",
       "div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
       ".sk-estimator-doc-link.fitted:hover {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-3);\n",
       "  color: var(--sklearn-color-background);\n",
       "  text-decoration: none;\n",
       "}\n",
       "\n",
       "/* Span, style for the box shown on hovering the info icon */\n",
       ".sk-estimator-doc-link span {\n",
       "  display: none;\n",
       "  z-index: 9999;\n",
       "  position: relative;\n",
       "  font-weight: normal;\n",
       "  right: .2ex;\n",
       "  padding: .5ex;\n",
       "  margin: .5ex;\n",
       "  width: min-content;\n",
       "  min-width: 20ex;\n",
       "  max-width: 50ex;\n",
       "  color: var(--sklearn-color-text);\n",
       "  box-shadow: 2pt 2pt 4pt #999;\n",
       "  /* unfitted */\n",
       "  background: var(--sklearn-color-unfitted-level-0);\n",
       "  border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
       "}\n",
       "\n",
       ".sk-estimator-doc-link.fitted span {\n",
       "  /* fitted */\n",
       "  background: var(--sklearn-color-fitted-level-0);\n",
       "  border: var(--sklearn-color-fitted-level-3);\n",
       "}\n",
       "\n",
       ".sk-estimator-doc-link:hover span {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       "/* \"?\"-specific style due to the `<a>` HTML tag */\n",
       "\n",
       "#sk-container-id-1 a.estimator_doc_link {\n",
       "  float: right;\n",
       "  font-size: 1rem;\n",
       "  line-height: 1em;\n",
       "  font-family: monospace;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "  border-radius: 1rem;\n",
       "  height: 1rem;\n",
       "  width: 1rem;\n",
       "  text-decoration: none;\n",
       "  /* unfitted */\n",
       "  color: var(--sklearn-color-unfitted-level-1);\n",
       "  border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 a.estimator_doc_link.fitted {\n",
       "  /* fitted */\n",
       "  border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
       "  color: var(--sklearn-color-fitted-level-1);\n",
       "}\n",
       "\n",
       "/* On hover */\n",
       "#sk-container-id-1 a.estimator_doc_link:hover {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-3);\n",
       "  color: var(--sklearn-color-background);\n",
       "  text-decoration: none;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 a.estimator_doc_link.fitted:hover {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-3);\n",
       "}\n",
       "</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>LogisticRegression(solver=&#x27;liblinear&#x27;)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow fitted\">&nbsp;&nbsp;LogisticRegression<a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.5/modules/generated/sklearn.linear_model.LogisticRegression.html\">?<span>Documentation for LogisticRegression</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></label><div class=\"sk-toggleable__content fitted\"><pre>LogisticRegression(solver=&#x27;liblinear&#x27;)</pre></div> </div></div></div></div>"
      ],
      "text/plain": [
       "LogisticRegression(solver='liblinear')"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.linear_model import LogisticRegression\n",
    "\n",
    "# 通过LogisticRegression类定义一个逻辑回归模型名字叫lr\n",
    "lr = LogisticRegression(solver='liblinear')\n",
    "\n",
    "# 对lr模型进行训练(fit)\n",
    "lr.fit(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "eb0577aa-fcb0-4b80-a401-9ed78a2acaac",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-0.29172838]\n",
      "[[ 2.83459971e-02  1.11560839e-04 -1.32182429e-02  7.30318394e-01\n",
      "   1.89679630e-01 -1.48382562e-01 -1.06334384e+00  5.52935328e-01\n",
      "   7.00935455e-01 -1.95898728e-01 -5.08232049e-01 -8.41468386e-01\n",
      "   5.79033754e-01 -1.02766249e+00 -5.19017338e-01 -3.10135176e-01\n",
      "   8.35370923e-02  4.42778942e-01  9.71368096e-01 -4.01602058e-02\n",
      "  -2.75628655e-01 -1.95842402e-01  4.20822787e-01  2.60897108e-01\n",
      "  -1.99318913e-02 -4.50967022e-01 -5.02549362e-01  4.01945877e-03\n",
      "   1.67259832e-01 -6.36213576e-03 -4.30245089e-01 -2.64004466e-02\n",
      "  -3.24769071e-01 -1.61723463e-01  9.33220864e-02  1.01442068e-01\n",
      "   2.42393806e-01  4.84031059e-02 -4.54959570e-01 -1.27565722e-01\n",
      "  -7.68505519e-02  3.92516924e-01 -6.07394752e-01 -3.24769071e-01\n",
      "  -1.61723463e-01  9.33220864e-02  1.01442068e-01 -4.82720054e-01\n",
      "   3.70454055e-01 -1.35092384e-02 -1.65953142e-01 -2.38576417e-01\n",
      "   2.64742586e-02 -4.20605586e-02 -3.75656631e-02  2.21807966e-01\n",
      "  -3.75526255e-01 -1.38010090e-01 -3.65469470e-01 -7.63200171e-03\n",
      "  -1.44389848e-01  2.25762940e-01 -4.81778755e-02 -1.39177028e-01\n",
      "   6.11618416e-02 -1.65535318e-01 -3.55524061e-01  6.37956808e-02\n",
      "   2.23332990e-02 -3.14061679e-01  5.70413506e-01 -8.62141886e-01]]\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[0.028345997053028878]</td>\n",
       "      <td>duration</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[0.00011156083861646167]</td>\n",
       "      <td>amount</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>[-0.013218242935376488]</td>\n",
       "      <td>age</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>[0.7303183941364161]</td>\n",
       "      <td>checking_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>[0.1896796302794579]</td>\n",
       "      <td>checking_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>67</th>\n",
       "      <td>[0.0637956808257408]</td>\n",
       "      <td>depends_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>68</th>\n",
       "      <td>[0.02233329897414984]</td>\n",
       "      <td>telephon_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>69</th>\n",
       "      <td>[-0.3140616788354817]</td>\n",
       "      <td>telephon_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>70</th>\n",
       "      <td>[0.5704135060600279]</td>\n",
       "      <td>foreign_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>71</th>\n",
       "      <td>[-0.8621418859213469]</td>\n",
       "      <td>foreign_2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>72 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                        coef     columns\n",
       "0     [0.028345997053028878]    duration\n",
       "1   [0.00011156083861646167]      amount\n",
       "2    [-0.013218242935376488]         age\n",
       "3       [0.7303183941364161]  checking_1\n",
       "4       [0.1896796302794579]  checking_2\n",
       "..                       ...         ...\n",
       "67      [0.0637956808257408]   depends_2\n",
       "68     [0.02233329897414984]  telephon_1\n",
       "69     [-0.3140616788354817]  telephon_2\n",
       "70      [0.5704135060600279]   foreign_1\n",
       "71     [-0.8621418859213469]   foreign_2\n",
       "\n",
       "[72 rows x 2 columns]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查看模型结果\n",
    "print(lr.intercept_ )\n",
    "print(lr.coef_)\n",
    "\n",
    "# 把变量名称和系数对应在一起方便查看\n",
    "pd.DataFrame(list(zip(np.transpose(lr.coef_), X_train.columns)), columns=['coef', 'columns'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9cbda017-9412-4d14-a7dd-82c4d3f43b1a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
